import service from '@api/config';
import { Get, Post, Put, Delete } from '@api/axiosType'; // 接口泛型

// 封装 get 方法，类型为Get
const get: Get = async (url, config) => {
    const response = await service.get(url, { ...config });
    return response.data;
};

const post: Post = async (url, params, config) => {
    const response = await service.post(url, params, { ...config });
    return response.data;
};

const put: Put = async (url, params, config) => {
    const response = await service.put(url, params, { ...config });
    return response.data;
};

const del: Delete = async (url, config) => {
    const response = await service.delete(url, { ...config });
    return response.data;
};

// 使用 request 统一调用
const request = { get, post, put, del };

export default request;
